package com.AAA.service.Impl.scl;

import com.AAA.entity.MyPage;
import com.AAA.entity.scl.TTestRecondScl;
import com.AAA.entity.User;
import com.AAA.service.scl.TTestRecondSclService;
import com.AAA.dao.scl.TTestRecondSclMapper;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * (TTestRecondScl)表服务实现类
 *
 * @author makejava
 * @since 2022-11-04 14:00:01
 */
@Service
public class TTestRecondSclServiceImpl implements TTestRecondSclService {
   @Autowired
   private TTestRecondSclMapper tTestRecondSclDao;

   @Override
   public Boolean addHf(HttpServletRequest request, HttpSession session) {
      User user1 = (User) session.getAttribute("user");
      String create_by = user1.getUsername();
      String username = request.getParameter("username");
      String recond = request.getParameter("recond");
      String remark = request.getParameter("remark");
      Integer tester_id = tTestRecondSclDao.selectIdByusername(username);
      String yqcode = tTestRecondSclDao.selectYqcodeByName(username);
      Integer test_plan_id = tTestRecondSclDao.selectPlanIdByYqcode(yqcode);
      Date create_time = new Date();
      Boolean a = tTestRecondSclDao.insertAll(tester_id, recond, test_plan_id, create_time,create_by, remark);

      return a;
   }

   @Override
   public PageInfo queryAll(MyPage myPage, TTestRecondScl tTestRecondScl){
      PageHelper.startPage(myPage.getPage(), myPage.getLimit());
      return new PageInfo(tTestRecondSclDao.selectAllData(tTestRecondScl));
   }

   @Override
   public int delete(TTestRecondScl tTestRecondScl) {
      int delete = tTestRecondSclDao.deleteByPrimaryKey(tTestRecondScl);
      return delete;
   }

   @Override
   public boolean updateAll(TTestRecondScl tTestRecondScl,HttpSession session) {
      User user1 = (User) session.getAttribute("user");
      String update_by = user1.getUsername();
      tTestRecondScl.setUpdateBy(update_by);
      tTestRecondScl.setUpdateTime(new Date());
      int i = tTestRecondSclDao.updateByPrimaryKeySelective(tTestRecondScl);

      return i>=0?true:false;

   }

   @Override
   public int selectTestId(Integer testerId) {
      int i = tTestRecondSclDao.selectTestId(testerId);
      return i;
   }

   @Override
   public int selectIdByUsername(String username) {
      Integer i = tTestRecondSclDao.selectIdByusername(username);
      return i;
   }

}
